package com.tannm.doan.taskmanager.dataview;

import java.util.*;

import com.tannm.doan.taskmanager.Prefs;
import com.tannm.doan.taskmanager.database.DataRowNote;
import com.tannm.doan.taskmanager.database.Database;

import android.database.Cursor;

public class DataViewNote extends DataView {
	// Comparator type
	public class RowsComparator implements Comparator<DataViewItem> {
		public int compare(DataViewItem item1, DataViewItem item2) {
			String s1 = item1.sSubject;
			String s2 = item2.sSubject;
			return s1.compareTo(s2);
		}
	};

	// fields
	private RowsComparator fnCmp = null;

	// methods
	public DataViewNote(Database db, Prefs prefs) {
		super(db, prefs);
		sTableName = Database.sTableNameNotes;
		fnCmp = new RowsComparator();
	}

	@Override
	public void addItem(Cursor cr) {
		DataViewItem item = new DataViewItem();

		item.lID = cr.getLong(DataRowNote.Fid.ID);
		item.sSubject = cr.getString(DataRowNote.Fid.SUBJECT);

		rows.add(item);
	}

	@Override
	public void filterDataForView(DataViewItem item,
			final Calendar calStartDate, final int agendaViewType) {
		item.viewMode = agendaViewType;
	}

	@Override
	protected void filterDataPrepare(final Calendar calStartDate,
			final int agendaViewType) {

	}

	@Override
	public void sortView() {
		Collections.sort(rows, fnCmp);
	}

}
